package com.neusoft.elmboot.mapper;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.PointLog;

@Mapper
public interface PointLogMapper {
    @Insert("insert into pointLog values(null, #{userId},1, #{time})")
    public int savePointLog(PointLog il);

    @Select("select count(*) from pointLog where userId = #{userId} and state = 1")
    public int getPointLogByUserIdByTime(String userId, String time);
    
    public int deletePointLogByUserIdByTime(String userId, Integer count);
    
    @Delete("delete from pointLog where time < #{limitTime} and userId = #{userId}")
    public int updatePointLog(String userId, String limitTime);
    
    @Select("select count(*) from pointLog where userId = #{userId} and time = #{limitTime}")
    public int getExpirationPointLogByUserId(String userId, String limitTime);

    @Update("UPDATE pointlog SET state = '0'  WHERE userId = #{userId} AND state = '1' LIMIT #{amount}")
    public int updatePointLogByPay(@Param("userId") String userId, @Param("amount") BigDecimal amount);
}
